
var app = getApp();
 const httputil = require("../../utils/httputil.js")   //一定要引入，根据你自己写的上传文件路径
 Page({
     data: {
         photos: "",
         photos2: "",
         photos3: "",
      
 
     },

     checkidcard:function(){
       var idcard=this.data.photos;
       console.log("id:"+idcard)
       wx.showLoading({ title: '识别中' })
       wx.request({
         url: 'http://127.0.0.1:7001/checkid/ocr',
         data:{
           picOcr:"http://tmp/wx7e5677a93321f726.o6zAJsxDV3gHmfJu1plAlNaYNCGY.mTOzrFwMVwuO83e2d8845beb576a79791eee436ac19f.jpg"
         },
        method: 'POST',
      //   header: {
      //     'content-type': 'multipart/form-data'
      //  },
       success(res){
       wx.hideLoading();
       console.log(res)
       }
       });

     },
    formSubmit: function (e) {
      var photo = [this.data.photos, this.data.photos2, this.data.photos3]
      var picture = photo.join(",");
      let pictures = picture.substring(7);
      console.log(pictures)
      httputil.send_photo(photo, function (res) {
       //成功回调函数  你随便做操作
      
  
      })
    },
     
     touchphoto: function (e) {
         var that = this
         var no = e.currentTarget.id;
         if (no == "1") {
             wx.chooseImage({
                 count: 1, // 默认9
                 sizeType: ['original', 'compressed'],
                 sourceType: ['album', 'camera'], 
                 success: function(res) {
                     // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片
                     var tempFilePaths = res.tempFilePaths
                    that.setData({
                         photos: tempFilePaths

          })
                     console.log("选择照片为："+that.data.photos)
          
        }
       })
      
    } else if (no == "2") {
             wx.chooseImage({
                 count: 1, // 默认9
                 sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
                 sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
                 success: function(res) {
                     // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片
                    var tempFilePaths = res.tempFilePaths
                     that.setData({
                         photos2: tempFilePaths

          })
                     console.log(that.data.photos)
          
        }
       })
      
    } else if (no == "3") {
             wx.chooseImage({
                 count: 1, // 默认9
                 sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
                 sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
                success: function(res) {
                     // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片
                     var tempFilePaths = res.tempFilePaths
                     that.setData({
                         photos3: tempFilePaths

          })
                    console.log(that.data.photos)
          
        }
       })
      
    }
    
  }
 })
